﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;

namespace AAClicker
{
    public class AAException : System.Exception
    {
        public AAException() { }
        public AAException(String Message) : base(Message) { }
    }

    public class UnreachableArgs : EventArgs
    {
        WebExceptionStatus _httpStatusCode;
        string _httpStatusMessage;
        DateTime _loggedAt;

        public UnreachableArgs(WebExceptionStatus StatusCode, string StatusMessage)
        {
            _httpStatusCode = StatusCode;
            _httpStatusMessage = StatusMessage;
            _loggedAt = DateTime.Now;
        }

        public WebExceptionStatus StatusCode
        {
            get
            {
                return _httpStatusCode;
            }
        }

        public string StatusMessage
        {
            get
            {
                return _httpStatusMessage;
            }
        }

        public DateTime LoggedAt
        {
            get
            {
                return _loggedAt;
            }
        }

        public string Serialize()
        {
            StringBuilder bldr = new StringBuilder();
            bldr.Append(this.LoggedAt.ToString("d"));
            bldr.Append("\t");
            bldr.Append(this.StatusCode);
            bldr.Append("\t");
            bldr.Append(this.StatusMessage);

            return bldr.ToString();
        }

    }

    public class AAExceptionServiceUnreachable : AAException
    {
        static List<UnreachableArgs> _args = new List<UnreachableArgs>();
        public AAExceptionServiceUnreachable() : base("An Exception of Unreachable hass occurred") { }
        public AAExceptionServiceUnreachable(String Message) : base(Message) { }
        public AAExceptionServiceUnreachable(WebExceptionStatus HttpStatusCode, string HttpStatusDescription)
            : base("An Exception of Unreachable hass occurred, see Args for more details")
        {
            _args.Add(new UnreachableArgs(HttpStatusCode, HttpStatusDescription));
        }

        public static List<UnreachableArgs> ListExceptions()
        {
            return _args;
        }

        public static void ListExceptionsClear()
        {
            _args = new List<UnreachableArgs>();
        }
    }

}
